﻿Imports System.Text
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Documents
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Imaging
Imports System.Windows.Navigation
Imports System.Windows.Shapes

Namespace PeopleCounterWidget
	''' <summary>
	''' Interaction logic for PeopleCounter.xaml
	''' </summary>
	Partial Public Class PeopleCounter
		Inherits UserControl
		Public Sub New()
			InitializeComponent()
		End Sub

        Private mNumber As Integer
        Public Property Number As Integer
            Get
                Return mNumber
            End Get
            Set(ByVal value As Integer)
                mNumber = value
                DisplayNumber(mNumber.ToString())
            End Set
        End Property

		Private Sub DisplayNumber(ByVal number As String)
			If number.Length >= 1 Then
				Text4.Text = number.Substring(number.Length - 1, 1)
			Else
				Text4.Text = ""
			End If

			If number.Length >= 2 Then
				Text3.Text = number.Substring(number.Length - 2, 1)
			Else
				Text3.Text = ""
			End If

			If number.Length >= 3 Then
				Text2.Text = number.Substring(number.Length - 3, 1)
			Else
				Text2.Text = ""
			End If

			If number.Length >= 4 Then
				Text1.Text = number.Substring(number.Length - 4, 1)
			Else
				Text1.Text = ""
			End If
		End Sub
	End Class
End Namespace
